package com.csy.user.controller.owner;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.csy.commons.core.controller.BaseController;
import com.csy.commons.core.domain.BaseResponse;
import com.csy.commons.core.page.PageResult;
import com.csy.user.entity.owner.domain.vo.AjOwnerRoomRecordVo;
import com.csy.user.entity.owner.domain.vo.AjOwnerRoomVo;
import com.csy.user.entity.owner.service.AjOwnerRoomService;

//业主房间控制类
@RestController
@RequestMapping("/system/ownerRoom")
public class AjOwnerRoomController extends BaseController {

    @Autowired
    AjOwnerRoomService ajOwnerRoomService;

    /**
     * 查询业主集合
     * @param ajOwnerRoomVo
     * @return
     */
    @RequestMapping("/list")
    public PageResult getAjOwnerRoomList(AjOwnerRoomVo ajOwnerRoomVo){
        startPage();
        List<AjOwnerRoomVo> list = ajOwnerRoomService.getOwnerRoomList(ajOwnerRoomVo);
        return getData(list);
    }

    /**
     * 查询业主房间
     * @param id
     * @return
     */
    @GetMapping("/{ownerRoomId}")
    public BaseResponse<AjOwnerRoomVo> getOwnerRoom(@PathVariable("ownerRoomId")Long id){
        AjOwnerRoomVo ajOwnerRoomVo = new AjOwnerRoomVo();
        ajOwnerRoomVo.setOwnerRoomId(id);
        List<AjOwnerRoomVo> ownerRoomList = ajOwnerRoomService.getOwnerRoomList(ajOwnerRoomVo);
        return BaseResponse.success(ownerRoomList.get(0));
    }

    /**
     * 更新绑定房间信息
     * @param ownerRoom
     * @return
     */
    @PutMapping
    public BaseResponse<Integer> updateBindingRoom(@RequestBody AjOwnerRoomVo ownerRoom){
        int row = ajOwnerRoomService.bindingRoom(ownerRoom);
        return BaseResponse.success(row);
    }

















    @GetMapping("/record/{ownerRoomId}")
    public List<AjOwnerRoomRecordVo> getOwnerRoomRecords(@PathVariable("ownerRoomId")String ownerRoomId){
        List<AjOwnerRoomRecordVo> list = ajOwnerRoomService.getOwnerRoomRecords(ownerRoomId);

        return list;
    }


}
